﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DataServer.DTO;
using DataServer.DAO;
using DataServer.SalaryCalculation;

namespace DataServer.Models
{
    public class NhanVienCTL
    {
        private NhanVienDTO info = new NhanVienDTO();
        private NhanVienDAO data = new NhanVienDAO();
        private CalculationStrategy salaryCalculator;

        public NhanVienDTO NhanVien
        {
            get
            {
                return info;
            }
            set
            {
                info = value;
            }
        }

        public void SetSalaryCalculator(CalculationStrategy calculator)
        {
            salaryCalculator = calculator;
        }

        public bool insert()
        {
            return data.ThemNhanVien(info);
        }

        public bool delete()
        {
            return data.XoaNhanVien(info.MANV);
        }

        public bool update(int id)
        {
            return data.SuaNhanVien(id, info);
        }

        public List<NhanVienDTO> getDsNhanVien()
        {
            return data.LayDanhSachNhanVien();
        }

        public NhanVienDTO getNhanVien(int id)
        {
            return data.getNhanVien(id);
        }

        public List<string> GetColName()
        {
            return data.GetColName();
        }

        public int calculateSalary()
        {
            try
            {
                return salaryCalculator.computeSalary();
            }
            catch (Exception)
            {
                
                throw;
            }
        }
    }
}